package org.example.entity;

import lombok.Data;
import lombok.Getter;
import lombok.ToString;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.config.BeanPostProcessor;

import java.util.Date;

/**
 * org.example.entity
 *
 * @author 莫磊
 * @description
 * @date 2025/7/20
 */
@Getter
@ToString
public class User implements BeanNameAware, InitializingBean, DisposableBean {

    String name;

    Date date;

    public User() {
        System.out.println("第一步：构造方法");
    }

    /**
     * 第二步给bean赋值
     */
    public void setName(String name) {
        System.out.println("第二步，给bean赋值");
        this.name = name;
    }
    public void setDate(Date date) {
        this.date = date;
    }

    public void init() {
        System.out.println("第三步初始化bean");
    }

    /**
     * 第四步使用bean
     */

    public void destroyBean() {
        System.out.println("第五步，销毁bean");
    }

    @Override
    public void setBeanName(String name) {
        System.out.println("bean的名字为：" + name);
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("afterPropertiesSet方法");
    }
    @Override
    public void destroy() throws Exception {
        System.out.println("在销毁bean之前执行");
    }
}
